//
//  ZBsexView.m
//  meituan
//
//  Created by apple on 16/5/27.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ZBsexView.h"
@interface ZBsexView()<UIPickerViewDataSource,UIPickerViewDelegate>
@property(nonatomic,strong)UIPickerView *pickview;
@property(nonatomic,strong)NSArray *array;
@property(nonatomic,strong)UIButton *butten;

@property(nonatomic,strong)NSString *sex;
@end
@implementation ZBsexView
-(NSArray *)array
{
    if (!_array) {
        _array = [NSArray arrayWithObjects:@"男",@"女", nil];
    }
    return _array;
}
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
    }
    return self;

}
-(void)setUpUI
{
    
    self.hidden = YES;
    self.pickview = [[UIPickerView alloc]init];
    self.pickview.backgroundColor = [UIColor whiteColor];
    self.pickview.dataSource = self;
    self.pickview.delegate = self;
    
    self.sex = @"男";
    
    self.butten = [[UIButton alloc]init];
    [self.butten addTarget:self action:@selector(makersurnBtnClic) forControlEvents:UIControlEventTouchUpInside];
    self.butten.backgroundColor = kbgColor;
    [self.butten setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.butten setTitle:@"确定" forState:UIControlStateNormal];
    
    [self addSubview:self.pickview];
    [self addSubview:self.butten];


}
-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.pickview.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height-40*Kscr);
    self.butten.frame = CGRectMake(0, self.frame.size.height-40*Kscr, self.frame.size.width, 40*Kscr);
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    return 2;
}
- (nullable NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component __TVOS_PROHIBITED
{
    
    return self.array[row];
}- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component __TVOS_PROHIBITED
{
    self.sex = self.array[row];

}

-(void)makersurnBtnClic
{

    [self.deleget SexString:self.sex];
    self.hidden = YES;
}
-(void)ShowSexView
{
    
    NSLog(@"222");
    
    self.hidden = NO;
}
-(void)hidensexview
{
    self.hidden = YES;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
